package org.xqp.pet.domain;


import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.util.StringUtils;
import org.xqp.basic.domain.BaseDomain;
import org.xqp.org.domain.Shop;
import org.xqp.user.domain.User;

import java.math.BigDecimal;
import java.util.Date;

/**
 * 宠物信息
 */

@Data
public class Pet extends BaseDomain {

    //宠物下架常量
    public static final int STATE_OFFLINE = 0;
    //宠物上架常量
    public static final int STATE_ONLINE = 1;

    /**
     * 宠物姓名
     */
    private String name;
    /**
     * 宠物的一些照片或者介绍
     */
    private String resources;
    /**
     * 售价
     */
    private BigDecimal saleprice;
    /**
     * 下架时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
    private Date offsaletime;
    /**
     * 上架时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
    private Date onsaletime;
    /**
     * 状态  0下架   1上架
     */
    private Integer state = 0;
    /**
     * 成本价
     */
    private BigDecimal costprice;
    /**
     * 创建时间 也就是收购宠物的时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
    private Date createtime= new Date();
    /**
     *
     */
    private Long type_id;
    /**
     * 宠物类型
     */
    private PetType type;
    /**
     * 店铺id  如果宠物被售出店铺id就为null
     */
    private Long shop_id;
    /**
     *
     */
    private Shop shop;
    /**
     * 购买宠物用户的id
     */
    private Long user_id;
    /**
     *
     */
    private User user;
    /**
     *
     */
    private Long search_master_msg_id;
    /**
     * 宠物明细详情
     */
    private PetDetail detail = new PetDetail();

    /**
     * 宠物库存
     * @return
     */
    private Integer store_number;
    public String getPic(){
        if(StringUtils.hasLength(resources)){
            return resources.split(",")[0];
        }
        return "";
    }

}
